import cv2
import numpy as np
while True:
    h_min=cv2.getTrackbarPos("Hue Min","TrackBars")
    h_max = cv2.getTrackbarPos("Hue Max", "TrackBars")
    s_min = cv2.getTrackbarPos("Sat Min", "TrackBars")
    s_max = cv2.getTrackbarPos("Sat Max", "TrackBars")
    v_min = cv2.getTrackbarPos("Val Min", "TrackBars")
    v_max = cv2.getTrackbarPos("Val Max", "TrackBars")
    lower = np.array([[h_min],[s_min],[v_min]])
    upper = np.array([[h_max],[s_max],[v_max]])
    mask=cv2.inRange(imgHSV,lower,upper)
    cv2.imshow("Mask",mask)
    imgResult=cv2.bitwise_and(img,img,mask=mask)
    cv2.imshow("Result",imgResult)
    if cv2.waitKey(1)==ord('q'):
        break
cv2.destroyAllWindows()